import { AuthService } from "@/shared/api/api.auth";
import { QueryClient, useMutation, useQuery } from "@tanstack/react-query";
import { useRouter } from "next/navigation"


export default function useLogout() {
    const router = useRouter()
    const queryClient = new QueryClient

    const logoutMutation = useMutation(
        {
            mutationFn: AuthService.logout,
            onSuccess() {
                router.push('/auth');
            }
        }, queryClient
    );
    return {
        logout: logoutMutation.mutate
    }
}

